package com.mes.cloud.util;



/**
 * @Description 个性化开发
 * @author: wxm
 * @date: 2019/5/20 10:50
 * @version: 1.0
 */
public class TemplateUtil {

    /**
     * @Description 初始化MetaObjectIntercept
     * @date:   2019/5/20 10:54
     * @param bizIntercept
     * @return: T
     */
    @SuppressWarnings("unchecked")
    public static <T> T initMetaObjectIntercept(String bizIntercept) throws Exception {
        Object o = initIntercept(bizIntercept);
        if (o == null) {
            //返回默认拦截器
        }
        return (T)o;
    }

    /**
     * @Description 实例化拦截器
     * @date:   2019/5/20 10:52
     * @param bizIntercept
     * @return: T
     */
    @SuppressWarnings("unchecked")
    public static <T> T initIntercept(String bizIntercept) throws Exception {
        if (!StringUtils.isEmpty(bizIntercept)) {
            try {
                // 实例化自定义拦截器
                return (T) Class.forName(bizIntercept).newInstance();
            } catch (Exception e) {
                e.printStackTrace();
                throw new Exception("实例化拦截器异常，请检查类是否存在:" + bizIntercept);
            }
        }
        return null;
    }
}
